package com.decent.manager.system.dto;

import com.decent.common.entity.manager.SystemUser;
import com.decent.common.validator.operate.Add;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.NotNull;

/**
 * 员工数据传输对象
 *
 * @className: SystemUserDTO
 * @author: wangyan
 * @date: 2022/4/16
 **/
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Data
public class SystemUserDTO extends SystemUser {
    private static final long serialVersionUID = 1033531178249681685L;/**
     * 当前页数
     */
    private Integer pageNumber;
    /**
     * 每页条数
     */
    private Integer pageSize;
    /**
     * 角色id
     */
    @NotNull(message = "请选择角色", groups = {Add.class})
    private Long roleId;

    /**
     * 初始化分页数据
     */
    public void initPage() {
        if (pageNumber == null || pageNumber <= 0) {
            pageNumber = 1;
        }
        int pageSizeUpperLimit = 100;
        if (pageSize == null || pageSize <= 0 || pageSize > pageSizeUpperLimit) {
            pageSize = 10;
        }
    }
}
